package com.hp.airmap.main;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;

import com.hp.airmap.R;
import com.hp.airmap.common.BaseActivity;
import com.hp.airmap.input.MvpActivity;
import com.hp.airmap.input.MyAdapter;
import com.hp.airmap.model.Photo;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 本框架适用于小中型项目，使用MVP+RxJava+Retrofit+Picasso+Realm搭建
 * MainActivity 展示ButterKnife和BaseQuickAdapter的基本用法
 * 日期：2017/3/16
 * 作者：胡鹏
 */
public class MainActivity extends BaseActivity  {

    //这里是ButterKnife 自动生成的注解
    @BindView(R.id.rvAlbum)
    RecyclerView rvAlbum;
    @BindView(R.id.btCrash)
    Button btCrash;
    @BindView(R.id.btMore)
    Button btMore;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        List<Photo> album=new ArrayList<>();
        album.add(new Photo("广州","天气很潮湿",""));
        album.add(new Photo("北京","正在下雪",""));
        MyAdapter adapter=new MyAdapter(R.layout.item_describe);
        adapter.setNewData(album);

        rvAlbum.setAdapter(adapter);
    }

    /**
     * 这里是ButterKnife自动生成的点击事件
     * @param view
     */
    @OnClick({R.id.btCrash,R.id.btMore})
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btCrash:
                //APP发生的错误时
                throw new RuntimeException("我抛出了一个错误，错误原因会在屏幕显示");
            case R.id.btMore:
                go(MvpActivity.class);
                break;
        }

    }

}
